import pandas as pd 
import matplotlib.pyplot as plt


class DataVisual :
    def __init__(self,filename):
        self.filename = filename +".csv"
        self.data = None


    def read_csv(self) :
        self.data = pd.read_csv(self.filename,encoding='GBK')
    
    def jobcity(self) :
        d = {}
        for citys in self.data["地区"] :
            if citys not in d.keys() :
                d[citys] = 1
            else :
                d[citys] += 1
        print(d)
        place_name = d.keys()
        place_count = d.values()
        plt.rcParams["font.sans-serif"] = ["SimHei"]
        plt.rcParams["axes.unicode_minus"] = False 
        plt.figure(figsize=(18,6), dpi=150)
        plt.pie(place_count,labels=place_name,autopct="%1.2f%%",textprops={"fontsize":5})
        plt.axis("equal") 
        plt.title("工作机会")
        plt.legend()
        plt.show()

    def maxsa(self):
        maxsadata = []
        maxsa_df = self.data[self.data["地区"]=="北京"]
        for maxsa in maxsa_df["最高薪资"] :
            maxsadata.append(maxsa)
        print(maxsadata)

a=DataVisual('1') 
a.read_csv()
a.maxsa()